<?php
include_once 'phpFlickr.php';
include_once 'AbstractPicSync.php';
class  FlickrPicSync extends AbtractPicSync
{
	public $api_key="13a6db2d27fad6db5d74d110242476c9";
	public $secret="01236100024a6e45";
	public $flickr=null;
	
	public function getSession()
	{
		if(!isset($_SESSION)){
			session_start();
		}
		if(!isset($_SESSION['phpFlickr_auth_token'])){
			$this->flickr=new phpFlickr($this->api_key,$this->secret);
			$this->flickr->auth("delete",FALSE);//you can just use $fk->auth(); is fine
		}
	}
	
	public function getAlbums(){

		//$this->flickr=new phpFlickr($this->api_key,$this->secret);
		//$this->flickr->auth("read",FALSE);//you can just use $fk->
		//$user=$this->flickr->test_login();
		//$user_a=json_decode($user,true);
		//$nsid =  $user_a['user']['id'];
		//echo $this->flickr->photosets_getList($nsid);
		echo $this->flickr->photos_search(array("user_id"=>"me"));
	}
	
	public function  addAlbum($albumName)
	{
		
	}
	
	public function deleteAlbum($albumId)
	{
		
	}
	
	
	public function  uploadPhoto($albumId, $photo)
	{
		$response = $this->flickr->async_upload($photo,"powerstar","King of andra","PK",FALSE,TRUE,TRUE);
		$response_a=json_decode($response,true);
        if (!empty($response_a['message'])) 
        	echo $response_a['message'];
        else 
        	echo "photo uploaded successfully";
	}
	
	public function deletePhoto($albumId, $photoId)
	{
		//$this->flickr->auth("delete",FALSE);
        $response = $this->flickr->photos_delete($photoId);
        $response_a=json_decode($response,true);
        if (!empty($response_a['message'])) 
        	echo $response_a['message'];
        else 
        	echo "photo deleted successfully";
        	
	}
		
}
?>
